package gui5e;

import java.util.*;
import processing.core.PApplet;
import controlP5.*;

public class LeftPanel extends Panel{

	//fields
	
	//constructors
	public LeftPanel(int s_, int pr_, PApplet pa_, ControlP5 c_){
		super(s_, pr_, pa_);
		  ctrl = c_;
		  accordion =  ctrl.addAccordion("acc_l");
	}
	
	//methods
	
	/// the update method for the panel
	public void draw(PApplet p_){
		if(!isExisting){
			 for (Map.Entry<String, Group> entry : ctrlGroups.entrySet()) {
				    Group group_ = entry.getValue();
				    accordion.addItem(group_)
				    	.setPosition((x+10), GUI.innerTop +20)
				    	.setWidth(GUI.panelLeftWidth - 20)
				    	;
				}
			  {{accordion.open(1);}};
			isExisting=true;
		}
			if(!isWaiting){
			//size&position  
			switch(mode_){
				  case 's': if(x< 0) x = x + GUI.PanelSpeed; else mode_ = 'v';break;
				  case 'h': if(x> GUI.panelLeftWidth*(-1)) x = x - GUI.PanelSpeed; else mode_ = 'm';break;
				  case 'v': x=0; break;
				  case 'm': x=GUI.panelLeftWidth*(-1); break;
			 } 
			//background
			p_.fill(GUI.backgroundPanel[0],GUI.backgroundPanel[1],GUI.backgroundPanel[2], GUI.backgroundPanel[3]);
			if(GUI.borderPanel.length < 2) p_.noStroke(); else p_.stroke(GUI.borderPanel[0],GUI.borderPanel[1],GUI.borderPanel[2], GUI.borderPanel[3]);
			GUI.innerLeft = x;
			p_.rect(x, GUI.innerTop, GUI.panelLeftWidth, GUI.innerHeight);	  
			//toolboxes
			ctrl.draw();
			accordion.setPosition((x+10), GUI.innerTop +20);
			}	    
		}
}
